package com.gxa.modules.service.impl;

import com.gxa.common.vo.JsonResult;
import com.gxa.common.vo.PageRecv;
import com.gxa.common.vo.PageResult;
import com.gxa.common.vo.ResultVo;
import com.gxa.modules.mapper.Loanafter_CheckReportMapper;
import com.gxa.modules.pojo.Checkreport_Document;
import com.gxa.modules.pojo.LoanSearch;
import com.gxa.modules.pojo.Loanafter_Checkreport;
import com.gxa.modules.service.Loanafter_CheckReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * Created with IntelliJ IDEA.
 * User: 张剑宇
 * Date: 2021/12/27 10:00
 * Description:
 * Version: V1.0
 */
@Service
public class Loanafter_CheckReportServiceImpl implements Loanafter_CheckReportService {
    @Autowired(required=false)
    private Loanafter_CheckReportMapper loanafter_checkReportMapper;

    //添加贷后检查报告
    @Override
    public ResultVo addReport(Loanafter_Checkreport loanafter_checkreport) {
        loanafter_checkReportMapper.addReport(loanafter_checkreport);
        ResultVo resultVo=new ResultVo();
        resultVo.setCode(200);
        resultVo.setMsg("添加成功！");
        resultVo.setData(loanafter_checkreport.getLoanafter_checkreport_id());
        return  resultVo;
    }


    //查询贷后检查报告
    @Override
    public JsonResult queryReport(PageRecv<LoanSearch> pageRecv) {
        //对查询页面参数计算
        Integer currentPage=pageRecv.getCurrentPage();
        Integer pageSize=pageRecv.getPageSize();
        Integer limit1=(currentPage-1)*pageSize;
        pageRecv.setCurrentPage(limit1);

        //调用Mapper方法获取返回结果
        List<Loanafter_Checkreport> list=loanafter_checkReportMapper.queryReport(pageRecv);
        Integer count =loanafter_checkReportMapper.queryReportCount(pageRecv.getData());
        //将结果塞入R
        JsonResult r=new JsonResult();
        r.setData(list);
        r.setCode(200);
        r.setMsg("查询成功！");
        r.setCount(count);
        return r;
    }

    @Override
    public ResultVo addDocument(Checkreport_Document document) {

        loanafter_checkReportMapper.addDocument(document);
        ResultVo resultVo=new ResultVo();
        resultVo.setCode(200);
        resultVo.setMsg("添加成功！");
        resultVo.setData(document.getCheckreport_document_id());
        return  resultVo;
    }
}
